<div class="wrap-color-lightblue">
    <div class="container theme-showcase bkcolor2" role="main" style="padding-top: 15px;">
        <ol class="breadcrumb">
            <li><a href="{:url('/index')}">首页</a></li>
            <li><a href="{:url('/index/user')}">个人中心</a></li>
            <li class="active">修改资料</li>
        </ol>
        <div class="bs-example bs-example-tabs" data-example-id="togglable-tabs">
            <ul id="myTabs" class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">修改资料</a>
                </li>
                <li role="presentation" class=""><a href="#profile" role="tab" id="profile-tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">账户信息</a>
                </li>
                <li role="presentation" class=""><a href="#dropdown" role="tab" id="dropdown-tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">账户绑定</a>
                </li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <!-- change message start -->
                <div role="tabpanel" class="tab-pane fade active in tab-wrap" id="home" aria-labelledby="home-tab">
                    <form class="form-horizontal" method="post" action="{:url('/index/user/change/sign/0')}">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">真实姓名</label>
                            <div class="col-sm-8">
                                <input type="text" name="realname" class="form-control" id="inputEmail3" value="<?php echo $info['realname']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-8">
                                <?php if($info['sex']==2){ ?>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" checked value="2">男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="1">女
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="0">保密
                                </label>
                                <?php }elseif($info['sex']==1){ ?>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="1">男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" checked value="1">女
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="1">保密
                                </label>
                                <?php }else{ ?>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="2">男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="1">女
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" checked value="0">保密
                                </label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText1" class="col-sm-2 control-label">生日</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText1" name="birthday" placeholder="1997-09-08" value="<?php echo date('Y-m-d',$info['birthday']); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText2" class="col-sm-2 control-label">所在公司</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText2" name="company" value="<?php echo $info['company']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText3" class="col-sm-2 control-label">职位</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText3" name="occupation" value="<?php echo $info['occupation']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText4" class="col-sm-2 control-label">居住地址</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText4" name="address" value="<?php echo $info['address']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText5" class="col-sm-2 control-label">微博</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText5" name="weibo" value="<?php echo $info['weibo']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputText6" class="col-sm-2 control-label">微信</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="inputText6" name="wechat" value="<?php echo $info['wechat']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="textArea1" class="col-sm-2 control-label">个性签名</label>
                            <div class="col-sm-8">
                                <textarea class="form-control" name="signature" rows="3" id="textArea1"><?php echo $info['signature']; ?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-4 col-sm-4">
                                <button type="submit" class="btn btn-primary btn-block">保 存</button>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- change message end
                =================================================== -->
                <!-- Account information start -->
                <div role="tabpanel" class="tab-pane fade tab-wrap" id="profile" aria-labelledby="profile-tab">
                    <form id="user-form" class="form-horizontal" method="post" action="{:url('/index/user/change/sign/1')}">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="username" name="username" value="<?php echo $info['username']; ?>">
                            </div>
                            <div class="col-sm-5">
                                <span id="edit-warn-name"><i class="glyphicon glyphicon-remove"></i>该用户名已被占用</span>
                                <i id="edit-success-name" class="glyphicon glyphicon-ok"></i>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="email1" class="col-sm-2 control-label">邮 箱</label>
                            <div class="col-sm-4">
                                <input type="email" class="form-control" id="email1" name="email" value="<?php echo $info['email']; ?>">
                            </div>
                            <div class="col-sm-5">
                                <span id="edit-warn-email"><i class="glyphicon glyphicon-remove"></i>邮箱格式不正确</span>
                                <i id="edit-success-email" class="glyphicon glyphicon-ok"></i>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword1" class="col-sm-2 control-label">密 码</label>
                            <div class="col-sm-4">
                                <input type="password" name="password" class="form-control" id="inputPassword1" placeholder="6~24位密码">
                            </div>
                            <div class="col-sm-5 edit-tips">
                                <i class="glyphicon glyphicon-info-sign"></i> 不填则不修改
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-4">
                                <button type="button" id="btn-submit" class="btn btn-primary btn-block">保 存</button>
                            </div>
                            <div class="col-sm-2">
                                <img id="loading" src="__INDEX__/images/loading.gif" style="display: none; width:34px; height:34px;">
                            </div>
                        </div>
                    </form>
                </div>
                <!-- Account information end
                =================================================== -->
                <!-- Account binding start  -->
                <div role="tabpanel" class="tab-pane fade tab-wrap" id="dropdown" aria-labelledby="dropdown-tab">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="button0" class="col-sm-2 control-label">新浪微博账号</label>
                            <div class="col-sm-8">
                                <button type="button" id="button0" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> 添加绑定</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="button1" class="col-sm-2 control-label">QQ账号</label>
                            <div class="col-sm-8">
                                <button type="button" id="button1" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> 添加绑定</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="button2" class="col-sm-2 control-label">微信账号</label>
                            <div class="col-sm-8">
                                <button type="button" id="button2" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> 添加绑定</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="button3" class="col-sm-2 control-label">支付宝账号</label>
                            <div class="col-sm-8">
                                <button type="button" id="button3" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> 添加绑定</button>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- Account binding end
                =================================================== -->
            </div>
        </div>
    </div>
</div>
<script>
    $('#username').blur(function () {
        var username =  $('#username').val();
        $.ajax({
            method:"POST",
            url: "{:url('/index/user/checkusername')}",
            data:{'username':username},
            dataType:"json"
        }).done(function( data ) {
            if (parseInt(data) == 1) {
                $('#edit-warn-name').hide();
                $('#edit-success-name').show();
            }else if(parseInt(data) == 2){
                $('#edit-warn-name').text("用户名不能为空").show();
                $('#edit-success-name').hide();
            }else{
                $('#edit-warn-name').show();
                $('#edit-success-name').hide();
            }
        });
    });
    $('#email1').blur(function () {
        var email =  $('#email1').val();
        $.ajax({
            method:"GET",
            url: "{:url('/index/user/checkemail')}",
            data:{'email':email},
            dataType:"json"
        }).done(function( data ) {
            if (parseInt(data) == 1){
                $('#edit-warn-email').hide();
                $('#edit-success-email').show();
            }else if(parseInt(data) == 2){
                $('#edit-warn-email').hide();
                $('#edit-success-email').hide();
            }else{
                $('#edit-warn-email').show();
                $('#edit-success-email').hide();
            }
        });
    });
    $("#btn-submit").click(function(){
        var data = $('#user-form').serializeArray();
        $('#loading').show();
        $.ajax({
            method:"POST",
            url:"{:url('/index/user/update')}",
            data:data
        }).done(function(res){
            if (parseInt(res)==1){
                $('#mySmallModalLabel').text('修改成功');
                $('#popup').show();
            } else{
                $('#mySmallModalLabel').text('修改失败');
                $('#popup').show();
            }
            $('#loading').hide();
            setTimeout(function(){
                $('#popup').hide();
            },3000);
        });
    });
</script>